/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Quentin L
 */
@Entity
@Table(name = "customer_order")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CustomerOrder.findAll", query = "SELECT c FROM CustomerOrder c"),
    @NamedQuery(name = "CustomerOrder.findById", query = "SELECT c FROM CustomerOrder c WHERE c.id = :id"),
    @NamedQuery(name = "CustomerOrder.findByAmount", query = "SELECT c FROM CustomerOrder c WHERE c.amount = :amount"),
    @NamedQuery(name = "CustomerOrder.findByDeliveryType", query = "SELECT c FROM CustomerOrder c WHERE c.deliveryType = :deliveryType"),
    @NamedQuery(name = "CustomerOrder.findByDeliveryCost", query = "SELECT c FROM CustomerOrder c WHERE c.deliveryCost = :deliveryCost"),
    @NamedQuery(name = "CustomerOrder.findByDeliveryTime", query = "SELECT c FROM CustomerOrder c WHERE c.deliveryTime = :deliveryTime"),
    @NamedQuery(name = "CustomerOrder.findByCardType", query = "SELECT c FROM CustomerOrder c WHERE c.cardType = :cardType"),
    @NamedQuery(name = "CustomerOrder.findByCardNumber", query = "SELECT c FROM CustomerOrder c WHERE c.cardNumber = :cardNumber"),
    @NamedQuery(name = "CustomerOrder.findByCardExpiration", query = "SELECT c FROM CustomerOrder c WHERE c.cardExpiration = :cardExpiration"),
    @NamedQuery(name = "CustomerOrder.findByCardCrypt", query = "SELECT c FROM CustomerOrder c WHERE c.cardCrypt = :cardCrypt"),
    @NamedQuery(name = "CustomerOrder.findByConfirmationNumber", query = "SELECT c FROM CustomerOrder c WHERE c.confirmationNumber = :confirmationNumber"),
    @NamedQuery(name = "CustomerOrder.findByDateCreated", query = "SELECT c FROM CustomerOrder c WHERE c.dateCreated = :dateCreated"),
    @NamedQuery(name = "CustomerOrder.findByCustomerId", query = "SELECT c FROM CustomerOrder c WHERE c.customerId = :customerId"),
    @NamedQuery(name = "CustomerOrder.findByLastCustomerId", query = "SELECT c FROM CustomerOrder c WHERE c.customerId = :customerId AND c.dateCreated = (SELECT max(c2.dateCreated) FROM CustomerOrder c2)")})
public class CustomerOrder implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "amount")
    private BigDecimal amount;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "delivery_type")
    private String deliveryType;
    @Basic(optional = false)
    @NotNull
    @Column(name = "delivery_cost")
    private BigDecimal deliveryCost;
    @Basic(optional = false)
    @NotNull
    @Column(name = "delivery_time")
    private int deliveryTime;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "delivery_address")
    private String deliveryAddress;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "card_type")
    private String cardType;
    @Basic(optional = false)
    @NotNull
    @Column(name = "card_number")
    private long cardNumber;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "card_expiration")
    private String cardExpiration;
    @Basic(optional = false)
    @NotNull
    @Column(name = "card_crypt")
    private int cardCrypt;
    @Basic(optional = false)
    @NotNull
    @Column(name = "confirmation_number")
    private long confirmationNumber;
    @Basic(optional = false)
    @NotNull
    @Column(name = "date_created")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateCreated;
    @Basic(optional = false)
    @NotNull
    @Column(name = "customer_id")
    private int customerId;

    public CustomerOrder() {
    }

    public CustomerOrder(Integer id) {
        this.id = id;
    }

    public CustomerOrder(Integer id, BigDecimal amount, String deliveryType, BigDecimal deliveryCost, int deliveryTime, String deliveryAddress, String cardType, long cardNumber, String cardExpiration, int cardCrypt, long confirmationNumber, Date dateCreated, int customerId) {
        this.id = id;
        this.amount = amount;
        this.deliveryType = deliveryType;
        this.deliveryCost = deliveryCost;
        this.deliveryTime = deliveryTime;
        this.deliveryAddress = deliveryAddress;
        this.cardType = cardType;
        this.cardNumber = cardNumber;
        this.cardExpiration = cardExpiration;
        this.cardCrypt = cardCrypt;
        this.confirmationNumber = confirmationNumber;
        this.dateCreated = dateCreated;
        this.customerId = customerId;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public String getDeliveryType() {
        return deliveryType;
    }

    public void setDeliveryType(String deliveryType) {
        this.deliveryType = deliveryType;
    }

    public BigDecimal getDeliveryCost() {
        return deliveryCost;
    }

    public void setDeliveryCost(BigDecimal deliveryCost) {
        this.deliveryCost = deliveryCost;
    }

    public int getDeliveryTime() {
        return deliveryTime;
    }

    public void setDeliveryTime(int deliveryTime) {
        this.deliveryTime = deliveryTime;
    }

    public String getDeliveryAddress() {
        return deliveryAddress;
    }

    public void setDeliveryAddress(String deliveryAddress) {
        this.deliveryAddress = deliveryAddress;
    }

    public String getCardType() {
        return cardType;
    }

    public void setCardType(String cardType) {
        this.cardType = cardType;
    }

    public long getCardNumber() {
        return cardNumber;
    }

    public void setCardNumber(long cardNumber) {
        this.cardNumber = cardNumber;
    }

    public String getCardExpiration() {
        return cardExpiration;
    }

    public void setCardExpiration(String cardExpiration) {
        this.cardExpiration = cardExpiration;
    }

    public int getCardCrypt() {
        return cardCrypt;
    }

    public void setCardCrypt(int cardCrypt) {
        this.cardCrypt = cardCrypt;
    }

    public long getConfirmationNumber() {
        return confirmationNumber;
    }

    public void setConfirmationNumber(long confirmationNumber) {
        this.confirmationNumber = confirmationNumber;
    }

    public Date getDateCreated() {
        return dateCreated;
    }

    public void setDateCreated(Date dateCreated) {
        this.dateCreated = dateCreated;
    }

    public int getCustomerId() {
        return customerId;
    }

    public void setCustomerId(int customerId) {
        this.customerId = customerId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CustomerOrder)) {
            return false;
        }
        CustomerOrder other = (CustomerOrder) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.CustomerOrder[ id=" + id + " ]";
    }
    
}
